﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Drawing.Imaging;

namespace Algorithms_10.Tools
{
    public static class PixelColorer
    {
        public static void ColorPixel(Bitmap bmp, Point[] pointsToColor, Color clr)
        {
            BitmapData outputData = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), System.Drawing.Imaging.ImageLockMode.ReadWrite, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
            int stride = outputData.Stride;
            Point pixel = new Point(-1, -1);
            unsafe
            {
                byte* optPnt = (byte*)outputData.Scan0;
                foreach(Point p in pointsToColor)
                {
                    int pos = (stride * p.Y) + (p.X * 3);
                    optPnt[pos] = clr.B;
                    optPnt[pos + 1] = clr.G;
                    optPnt[pos + 2] = clr.R;
                }
            }
            bmp.UnlockBits(outputData);
        }

    }
}
